Git Product home page Git Product logo

Comments (6)

liufengyun avatar liufengyun commented on June 15, 2024 1

I wonder if typeChecks does not cover the compiler phase that perform the check for the given expected error above

Sorry for the late response. I checked the compiler code implementation of typeChecks, it does run PostTyper phase, which checks the type bounds.

I'd suggest create a minimized test without ScalaTest by using scala.compiletime.testing.typeChecks directly. If the error persists, then report a bug to the Scala 3 compiler.

from scalatest.

dhinojosa avatar dhinojosa commented on June 15, 2024 1

Filed: scala/scala3#18150

from scalatest.

cheeseng avatar cheeseng commented on June 15, 2024

@dhinojosa Hmm, fyi ScalaTest macro for Scala 3 just use scala.compiletime.testing.typeChecks to check that the given code does not compile, I wonder if typeChecks does not cover the compiler phase that perform the check for the given expected error above. @liufengyun Do you have any idea if that is the case?

from scalatest.

cheeseng avatar cheeseng commented on June 15, 2024

@dhinojosa @liufengyun This is an example without scalatest:

package com.example

object Test: 
  def main(args: Array[String]): Unit =
    val result = 
      scala.compiletime.testing.typeChecks(
        "trait RecursiveSelfTypeEntity[E <: RecursiveSelfTypeEntity[E]]: \n" +
        "  self: E => \n" +
        "  def create(): E \n" +
        "  def read(id: Long): Option[E] \n" +
        "  def update(f: E => E): E \n" +
        "  def delete(id: Long): Unit \n" +
        "\n" +
        "class Apple extends RecursiveSelfTypeEntity[Apple]: \n" +
        "  override def create(): Apple = ??? \n" +
        "  override def read(id: Long): Option[Apple] = ??? \n" +
        "  override def update(f: Apple => Apple): Apple = ??? \n" +
        "  override def delete(id: Long): Unit = ??? \n" +
        " \n" +
        "class Orange extends RecursiveSelfTypeEntity[Orange]: \n" +
        "  override def create(): Orange = ??? \n" +
        "  override def read(id: Long): Option[Orange] = ??? \n" +
        "  override def update(f: Orange => Orange): Orange = ??? \n" +
        "  override def delete(id: Long): Unit = ??? \n" + 
        " \n" +
        "class Banana extends RecursiveSelfTypeEntity[Apple]: \n" +
        "  override def create(): Apple = ??? \n" +
        "  override def read(id: Long): Option[Apple] = ??? \n" +
        "  override def update(f: Apple => Apple): Apple = ??? \n" +
        "  override def delete(id: Long): Unit = ???\n"
      )
    assert(false, "Should fail type check, but it didn't.")

@dhinojosa Would you like to report it to dotty issues?

from scalatest.

dhinojosa avatar dhinojosa commented on June 15, 2024

@cheeseng That last line will always fail since it is false, assert(false, "Should fail type check, but it didn't."). When I replaced it with assert(result, "Should fail type check, but it didn't.") it works fine. Let me know if you want to do a follow up test.

from scalatest.

dhinojosa avatar dhinojosa commented on June 15, 2024

Oh, wait, even if I place the result, this should actually fail. Sorry, brain fail on my part.

from scalatest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.