Skip to content

Commit d6c7e18

Browse files
committed
activate constrainResult fix in 3.4
1 parent 97e4401 commit d6c7e18

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ object ProtoTypes {
117117
def constrainResult(meth: Symbol, mt: Type, pt: Type)(using Context): Boolean =
118118
if (Inlines.isInlineable(meth)) {
119119
// Stricter behaviour in 3.4+: do not apply `wildApprox` to non-transparent inlines
120-
if (Feature.sourceVersion.isAtLeast(SourceVersion.future)) {
120+
if (Feature.sourceVersion.isAtLeast(SourceVersion.`3.4`)) {
121121
if (meth.is(Transparent)) {
122122
constrainResult(mt, wildApprox(pt))
123123
// do not constrain the result type of transparent inline methods

tests/neg-macros/i18174.check

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- [E172] Type Error: tests/neg-macros/i18174.scala:27:33 --------------------------------------------------------------
2+
27 | (charClassIntersection.rep() | classItem.rep()) // error
3+
| ^^^^^^^^^^^^^^^
4+
|No given instance of type pkg.Implicits.Repeater[pkg.RegexTree, V] was found.
5+
|I found:
6+
|
7+
| pkg.Implicits.Repeater.GenericRepeaterImplicit[T]
8+
|
9+
|But method GenericRepeaterImplicit in object Repeater does not match type pkg.Implicits.Repeater[pkg.RegexTree, V]
10+
|
11+
|where: V is a type variable with constraint <: Seq[pkg.CharClassIntersection]
12+
|.

tests/neg-macros/i18174.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// does not compile anymore in Scala 3.4+
2+
package pkg
3+
4+
import scala.language.`3.4`
5+
6+
trait P[+T]
7+
8+
extension [T](inline parse0: P[T])
9+
inline def | [V >: T](inline other: P[V]): P[V] = ???
10+
11+
extension [T](inline parse0: => P[T])
12+
inline def rep[V](inline min: Int = 0)(using repeater: Implicits.Repeater[T, V]): P[V] = ???
13+
14+
object Implicits:
15+
trait Repeater[-T, R]
16+
object Repeater:
17+
implicit def GenericRepeaterImplicit[T]: Repeater[T, Seq[T]] = ???
18+
19+
sealed trait RegexTree
20+
abstract class Node extends RegexTree
21+
class CharClassIntersection() extends Node
22+
23+
def classItem: P[RegexTree] = ???
24+
def charClassIntersection: P[CharClassIntersection] = ???
25+
26+
def x =
27+
(charClassIntersection.rep() | classItem.rep()) // error

tests/pos-macros/i18123.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// may not compile anymore in Scala 3.4+
22
package pkg
33

4+
import scala.language.`3.3`
5+
46
trait P[+T]
57

68
extension [T](inline parse0: P[T])

0 commit comments

Comments
 (0)