File tree 3 files changed +11
-0
lines changed
compiler/src/dotty/tools/dotc
3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -581,6 +581,7 @@ object Flags {
581
581
val LazyGiven : FlagSet = Given | Lazy
582
582
val InlineOrProxy : FlagSet = Inline | InlineProxy // An inline method or inline argument proxy */
583
583
val InlineMethod : FlagSet = Inline | Method
584
+ val InlineImplicitMethod : FlagSet = Implicit | InlineMethod
584
585
val InlineParam : FlagSet = Inline | Param
585
586
val InlineByNameProxy : FlagSet = InlineProxy | Method
586
587
val JavaEnumTrait : FlagSet = JavaDefined | Enum // A Java enum trait
Original file line number Diff line number Diff line change @@ -3939,10 +3939,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3939
3939
3940
3940
// Reasons NOT to eta expand:
3941
3941
// - we reference a constructor
3942
+ // - we reference an inline implicit def (see #19862)
3942
3943
// - we are in a pattern
3943
3944
// - the current tree is a synthetic apply which is not expandable (eta-expasion would simply undo that)
3944
3945
if arity >= 0
3945
3946
&& ! tree.symbol.isConstructor
3947
+ && ! tree.symbol.isAllOf(InlineImplicitMethod )
3946
3948
&& ! ctx.mode.is(Mode .Pattern )
3947
3949
&& ! (isSyntheticApply(tree) && ! functionExpected)
3948
3950
then
Original file line number Diff line number Diff line change
1
+ import scala .language .implicitConversions
2
+
3
+ object Test :
4
+ implicit inline def uhOh [A ](value : A ): A =
5
+ compiletime.error(" Should not have been called" )
6
+ def test =
7
+ // Compiles because `uhOh` fails to eta-expand and we fallback to `Predef.$conforms[A, A]`
8
+ summon[Function1 [Int , Int ]]
You can’t perform that action at this time.
0 commit comments