diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 32240e91da77..6b72f3a8b56e 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -117,7 +117,7 @@ object ProtoTypes { def constrainResult(meth: Symbol, mt: Type, pt: Type)(using Context): Boolean = if (Inlines.isInlineable(meth)) { // Stricter behaviour in 3.4+: do not apply `wildApprox` to non-transparent inlines - if (Feature.sourceVersion.isAtLeast(SourceVersion.future)) { + if (Feature.sourceVersion.isAtLeast(SourceVersion.`3.4`)) { if (meth.is(Transparent)) { constrainResult(mt, wildApprox(pt)) // do not constrain the result type of transparent inline methods diff --git a/tests/neg-macros/i18174.check b/tests/neg-macros/i18174.check new file mode 100644 index 000000000000..1f4396d6b5ca --- /dev/null +++ b/tests/neg-macros/i18174.check @@ -0,0 +1,12 @@ +-- [E172] Type Error: tests/neg-macros/i18174.scala:27:33 -------------------------------------------------------------- +27 | (charClassIntersection.rep() | classItem.rep()) // error + | ^^^^^^^^^^^^^^^ + |No given instance of type pkg.Implicits.Repeater[pkg.RegexTree, V] was found. + |I found: + | + | pkg.Implicits.Repeater.GenericRepeaterImplicit[T] + | + |But method GenericRepeaterImplicit in object Repeater does not match type pkg.Implicits.Repeater[pkg.RegexTree, V] + | + |where: V is a type variable with constraint <: Seq[pkg.CharClassIntersection] + |. diff --git a/tests/neg-macros/i18174.scala b/tests/neg-macros/i18174.scala new file mode 100644 index 000000000000..8bb5ffd51a3f --- /dev/null +++ b/tests/neg-macros/i18174.scala @@ -0,0 +1,27 @@ +// does not compile anymore in Scala 3.4+ +package pkg + +import scala.language.`3.4` + +trait P[+T] + +extension [T](inline parse0: P[T]) + inline def | [V >: T](inline other: P[V]): P[V] = ??? + +extension [T](inline parse0: => P[T]) + inline def rep[V](inline min: Int = 0)(using repeater: Implicits.Repeater[T, V]): P[V] = ??? + +object Implicits: + trait Repeater[-T, R] + object Repeater: + implicit def GenericRepeaterImplicit[T]: Repeater[T, Seq[T]] = ??? + +sealed trait RegexTree +abstract class Node extends RegexTree +class CharClassIntersection() extends Node + +def classItem: P[RegexTree] = ??? +def charClassIntersection: P[CharClassIntersection] = ??? + +def x = + (charClassIntersection.rep() | classItem.rep()) // error diff --git a/tests/pos-macros/i18123.scala b/tests/pos-macros/i18123.scala index 714850004d2c..d9127a918ee8 100644 --- a/tests/pos-macros/i18123.scala +++ b/tests/pos-macros/i18123.scala @@ -1,6 +1,8 @@ // may not compile anymore in Scala 3.4+ package pkg +import scala.language.`3.3` + trait P[+T] extension [T](inline parse0: P[T])