From b28d4c1cbe0a552091be7c83ea82924db636d7b2 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 11 Mar 2024 15:37:08 +0100 Subject: [PATCH] Revert "Take into account the result type of inline implicit conversions unless they are transparent" This reverts commit eb38e1f0fc38313ab17969a74664618900ace2e9. --- community-build/community-projects/munit | 2 +- community-build/community-projects/specs2 | 2 +- .../dotty/tools/dotc/typer/ProtoTypes.scala | 5 ++-- tests/neg-macros/i18174.scala | 27 ------------------- tests/neg-macros/i9685bis.check | 9 ------- tests/neg-macros/i9685bis.scala | 23 ---------------- 6 files changed, 4 insertions(+), 64 deletions(-) delete mode 100644 tests/neg-macros/i18174.scala delete mode 100644 tests/neg-macros/i9685bis.check delete mode 100644 tests/neg-macros/i9685bis.scala diff --git a/community-build/community-projects/munit b/community-build/community-projects/munit index c18fddb143b9..5c77d7316fc6 160000 --- a/community-build/community-projects/munit +++ b/community-build/community-projects/munit @@ -1 +1 @@ -Subproject commit c18fddb143b98e4c026dc118687410d52b187d88 +Subproject commit 5c77d7316fc66adaed64e9532ee0a45a668b01ec diff --git a/community-build/community-projects/specs2 b/community-build/community-projects/specs2 index ba01cca013d9..a618330aa808 160000 --- a/community-build/community-projects/specs2 +++ b/community-build/community-projects/specs2 @@ -1 +1 @@ -Subproject commit ba01cca013d9d99e390d17619664bdedd716e0d7 +Subproject commit a618330aa80833787859dae805d02e45d4304c42 diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 96b0be6d9bd8..46c12b244fbb 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -17,7 +17,6 @@ import Inferencing.* import ErrorReporting.* import util.SourceFile import TypeComparer.necessarySubType -import dotty.tools.dotc.core.Flags.Transparent import scala.annotation.internal.sharable import dotty.tools.dotc.util.Spans.{NoSpan, Span} @@ -107,14 +106,14 @@ object ProtoTypes { if !res then ctx.typerState.constraint = savedConstraint res - /** Constrain result with special case if `meth` is a transparent inlineable method in an inlineable context. + /** Constrain result with special case if `meth` is an inlineable method in an inlineable context. * In that case, we should always succeed and not constrain type parameters in the expected type, * because the actual return type can be a subtype of the currently known return type. * However, we should constrain parameters of the declared return type. This distinction is * achieved by replacing expected type parameters with wildcards. */ def constrainResult(meth: Symbol, mt: Type, pt: Type)(using Context): Boolean = - if (Inlines.isInlineable(meth) && meth.is(Transparent)) { + if (Inlines.isInlineable(meth)) { constrainResult(mt, wildApprox(pt)) true } diff --git a/tests/neg-macros/i18174.scala b/tests/neg-macros/i18174.scala deleted file mode 100644 index 8bb5ffd51a3f..000000000000 --- a/tests/neg-macros/i18174.scala +++ /dev/null @@ -1,27 +0,0 @@ -// 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/neg-macros/i9685bis.check b/tests/neg-macros/i9685bis.check deleted file mode 100644 index 45e7f85aa30d..000000000000 --- a/tests/neg-macros/i9685bis.check +++ /dev/null @@ -1,9 +0,0 @@ --- [E008] Not Found Error: tests/neg-macros/i9685bis.scala:23:4 -------------------------------------------------------- -23 | 1.asdf // error - | ^^^^^^ - | value asdf is not a member of Int, but could be made available as an extension method. - | - | The following import might make progress towards fixing the problem: - | - | import foo.Baz.toBaz - | diff --git a/tests/neg-macros/i9685bis.scala b/tests/neg-macros/i9685bis.scala deleted file mode 100644 index 0023d4d719b4..000000000000 --- a/tests/neg-macros/i9685bis.scala +++ /dev/null @@ -1,23 +0,0 @@ -package foo - -import scala.language.implicitConversions - -class Foo - -object Foo: - - inline implicit def toFoo(x: Int): Foo = Foo() - -class Bar - -object Bar: - inline given Conversion[Int, Bar] with - def apply(x: Int): Bar = Bar() - -class Baz - -object Baz: - transparent inline implicit def toBaz(x: Int): Baz = Baz() - -object Usage: - 1.asdf // error