Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version=$1
scala212=2.12.20
scala213=2.13.16
scala3LTS=3.3.6
scala3Next=3.7.0
scala3Next=3.7.1

cs resolve \
ch.epfl.scala:scalafix-interfaces:$version \
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object Dependencies {
val scala33 = "3.3.6"
val scala35 = "3.5.2"
val scala36 = "3.6.4"
val scala37 = "3.7.0"
val scala37 = "3.7.1"
val scala3LTS = scala33
val scala3Next = sys.props.getOrElse("scala3.nightly", scala37)

Expand Down
1 change: 1 addition & 0 deletions project/ScalafixBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
)

private val PreviousScalaVersion: Map[String, Option[String]] = Map(
scala37 -> Some("3.7.0")
)

override def buildSettings: Seq[Setting[_]] = List(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
rules = ExplicitResultTypes
*/
package test.explicitResultTypes

object EnumerationValue {
object Day extends Enumeration {
type Day = Value
val Weekday, Weekend = Value
}
object Bool extends Enumeration {
type Bool = Value
val True, False = Value
}
import Bool._
def day(d: Day.Value): Unit = ???
val d =
if (true) Day.Weekday
else Day.Weekend
day(d)
val b =
if (true) True
else False
Comment on lines +17 to +23
Copy link
Collaborator Author

@bjaglin bjaglin May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test infrastructure is not great to represent the intent of that change, but this was copied in order to skip scala3-next.

That's because the 3.7.1-RC1 PC is trying to be smarter when shortening types but gets fooled by the import Bool. somehow , and we end up with that code that does not compile

Suggested change
val d =
if (true) Day.Weekday
else Day.Weekend
day(d)
val b =
if (true) True
else False
val d: Value =
if (true) Day.Weekday
else Day.Weekend
day(d)
val b: Value =
if (true) True
else False
[error] -- [E007] Type Mismatch Error: /Users/brice.jaglin/git/scala/scalafix/scalafix-tests/output/src/main/scala-3next/test/explicitResultTypes/EnumerationValue.scala:15:18
[error] 15 |    if (true) Day.Weekday
[error]    |              ^^^^^^^^^^^
[error]    |      Found:    (test.explicitResultTypes.EnumerationValue.Day.Weekday :
[error]    |        test.explicitResultTypes.EnumerationValue.Day.Value)
[error]    |      Required: test.explicitResultTypes.EnumerationValue.Bool.Value
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[error] -- [E007] Type Mismatch Error: /Users/brice.jaglin/git/scala/scalafix/scalafix-tests/output/src/main/scala-3next/test/explicitResultTypes/EnumerationValue.scala:16:13
[error] 16 |    else Day.Weekend
[error]    |         ^^^^^^^^^^^
[error]    |      Found:    (test.explicitResultTypes.EnumerationValue.Day.Weekend :
[error]    |        test.explicitResultTypes.EnumerationValue.Day.Value)
[error]    |      Required: test.explicitResultTypes.EnumerationValue.Bool.Value
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[error] -- [E007] Type Mismatch Error: /Users/brice.jaglin/git/scala/scalafix/scalafix-tests/output/src/main/scala-3next/test/explicitResultTypes/EnumerationValue.scala:17:6
[error] 17 |  day(d)
[error]    |      ^
[error]    |      Found:    (test.explicitResultTypes.EnumerationValue.d :
[error]    |        test.explicitResultTypes.EnumerationValue.Bool.Value)
[error]    |      Required: test.explicitResultTypes.EnumerationValue.Day.Value
[error]    |
[error]    | longer explanation available when compiling with `-explain`

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just went through the recent changes of the PC and scala/scala3#22898 might be a candidate for the regression.

@tgodzik since you are the author, maybe you can confirm/infirm? I will end up filing an issue upstream eventually, but my knowledge of the dotty repo is limited so it will take me a while to write a unit test :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be some side effect of that PR yeah. It was a tricky part of the compiler. If you could just put the example in a issue I will take a look.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ach, I think I know what is going on. Those are path dependent types and it's not handled at all properly :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got something working, but I broke another test:
https://github.com/scala/scala3/compare/main...tgodzik:scala3:fix-path-dep?expand=1

I am not sure how to differentiate types that are actually in Scope from those that are not if they actually have the same symbol.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's try get scala/scala3#23124 merged, took me longer than expected

Copy link
Collaborator Author

@bjaglin bjaglin Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Taking note to simplify the test once 3.7.2-RC1 is tagged

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
rules = "ExplicitResultTypes"
ExplicitResultTypes.skipSimpleDefinitions = ["Lit"]
*/
package test.explicitResultTypes

object ExplicitResultTypesNil {
val nil = Nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ object ExplicitResultTypesBase {
object ExtraSpace {
def * = "abc".length
def ! = "abc".length
def foo_ = "abc".length
def `x` = "abc".length
def `x ` = "abc".length
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
rules = "ExplicitResultTypes"
ExplicitResultTypes.skipSimpleDefinitions = ["Lit"]
*/
package test.explicitResultTypes

object ExplicitResultTypesNil {
val nil = Nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ object ExplicitResultTypesBase {
object ExtraSpace {
def * : Int = "abc".length
def ! : Int = "abc".length
def foo_ : Int = "abc".length
def `x`: Int = "abc".length
def `x `: Int = "abc".length
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

package test.explicitResultTypes

object ExplicitResultTypesNil {
val nil: Nil.type = Nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

package test.explicitResultTypes

object ExplicitResultTypesNil {
val nil: scala.collection.immutable.Nil.type = Nil
}