Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertDoesNotCompile not works when creating mixins #2283

Open
goshacodes opened this issue Sep 22, 2023 · 4 comments
Open

assertDoesNotCompile not works when creating mixins #2283

goshacodes opened this issue Sep 22, 2023 · 4 comments

Comments

@goshacodes
Copy link

goshacodes commented Sep 22, 2023

scala version: 3.3.0

scalatest version: 3.2.16

class AsyncSyncMixinTest extends AnyFlatSpec {

  trait A { this: C => }

  trait B { this: D => }

  trait C

  trait D


  "abc" should "bcd" in {
    assertDoesNotCompile("new A with D")
  }

  "bcd" should "abc" in {
    assertDoesNotCompile("new B with C")
  }

}
  

ER: tests yield success
AR: tests fail

@goshacodes goshacodes changed the title assertDoesNotCompile not works with self types assertDoesNotCompile not works when creating mixins Sep 23, 2023
@cheeseng
Copy link
Contributor

@goshacodes The scala.compiletime.testing.typeChecks does not seems to catch this, @liufengyun I wonder if this is covered under typer phase and expected to work?

@goshacodes
Copy link
Author

Forgot to mention, this thing worked with scala 2 macro

@liufengyun
Copy link
Contributor

As far as I know, testing.typeChecks does not run the compiler phase refChecks. It can be verified by running the following command:

scalac -d out -Ystop-after:posttyper examples/Error.scala

For the following code:

// Error.scala
class AsyncSyncMixinTest {

  trait A { this: C => }

  trait B { this: D => }

  trait C

  trait D


  new A with D

  new B with C
}

But maybe it should run the phase refChecks. I'd suggest report it as an issue here: https://github.com/lampepfl/dotty/issues

@cheeseng
Copy link
Contributor

@goshacodes @liufengyun I think it is probably related to this ticket reported in Dotty earlier:

#2252

I have added a comment in the ticket to link here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants