Skip to content

Commit

Permalink
activate constrainResult fix in 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Dec 12, 2023
1 parent 97e4401 commit d6c7e18
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/neg-macros/i18174.check
Original file line number Diff line number Diff line change
@@ -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]
|.
27 changes: 27 additions & 0 deletions tests/neg-macros/i18174.scala
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions tests/pos-macros/i18123.scala
Original file line number Diff line number Diff line change
@@ -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])
Expand Down

0 comments on commit d6c7e18

Please sign in to comment.