Skip to content

Commit 6cddb42

Browse files
Merge pull request #6459 from dotty-staging/fix-#6395
Fix #6395: Drop expected type in inlineCall
2 parents 6429f7c + bf28a48 commit 6cddb42

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ object SymDenotations {
396396
// need to use initial owner to disambiguate, as multiple private symbols with the same name
397397
// might have been moved from different origins into the same class
398398

399-
/** The name with which the denoting symbol was created */
399+
/** The effective name with which the denoting symbol was created */
400400
final def originalName(implicit ctx: Context): Name = initial.effectiveName
401401

402402
/** The owner with which the denoting symbol was created. */

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ object Inliner {
6161
* @return An `Inlined` node that refers to the original call and the inlined bindings
6262
* and body that replace it.
6363
*/
64-
def inlineCall(tree: Tree, pt: Type)(implicit ctx: Context): Tree = {
64+
def inlineCall(tree: Tree)(implicit ctx: Context): Tree = {
6565

6666
/** Set the position of all trees logically contained in the expansion of
6767
* inlined call `call` to the position of `call`. This transform is necessary
@@ -102,11 +102,11 @@ object Inliner {
102102

103103
val tree1 = liftBindings(tree, identity)
104104
if (bindings.nonEmpty)
105-
cpy.Block(tree)(bindings.toList, inlineCall(tree1, pt))
105+
cpy.Block(tree)(bindings.toList, inlineCall(tree1))
106106
else if (enclosingInlineds.length < ctx.settings.XmaxInlines.value) {
107107
val body = bodyToInline(tree.symbol) // can typecheck the tree and thereby produce errors
108108
if (ctx.reporter.hasErrors) tree
109-
else new Inliner(tree, body).inlined(pt, tree.sourcePos)
109+
else new Inliner(tree, body).inlined(tree.sourcePos)
110110
}
111111
else
112112
errorTree(
@@ -384,7 +384,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
384384
}
385385

386386
/** The Inlined node representing the inlined call */
387-
def inlined(pt: Type, sourcePos: SourcePosition): Tree = {
387+
def inlined(sourcePos: SourcePosition): Tree = {
388388

389389
if (callTypeArgs.length == 1)
390390
if (inlinedMethod == defn.Compiletime_constValue) {
@@ -509,7 +509,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
509509
}
510510

511511
// Run a typing pass over the inlined tree. See InlineTyper for details.
512-
val expansion1 = inlineTyper.typed(expansion, pt)(inlineCtx)
512+
val expansion1 = inlineTyper.typed(expansion)(inlineCtx)
513513

514514
if (ctx.settings.verbose.value) {
515515
inlining.println(i"to inline = $rhsToInline")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,7 +2772,7 @@ class Typer extends Namer
27722772
!ctx.isAfterTyper &&
27732773
!ctx.reporter.hasErrors) {
27742774
tree.tpe <:< wildApprox(pt)
2775-
readaptSimplified(Inliner.inlineCall(tree, pt))
2775+
readaptSimplified(Inliner.inlineCall(tree))
27762776
}
27772777
else if (tree.symbol.isScala2Macro) {
27782778
if (ctx.settings.XignoreScala2Macros.value) {
@@ -2786,7 +2786,7 @@ class Typer extends Namer
27862786
// As the macro is implemented in the bootstrapped library, it can only be used from the bootstrapped compiler.
27872787
val Apply(TypeApply(Select(sc, _), _), args) = tree
27882788
val newCall = ref(defn.InternalStringContextModule_f).appliedTo(sc).appliedToArgs(args)
2789-
Inliner.inlineCall(newCall, pt)
2789+
readaptSimplified(Inliner.inlineCall(newCall))
27902790
} else {
27912791
ctx.error("Scala 2 macro cannot be used in Dotty. See http://dotty.epfl.ch/docs/reference/dropped-features/macros.html", tree.sourcePos)
27922792
tree

tests/pos/i6395.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Foo {
2+
inline def (self: Int) foo (that: Int): Int = 5
3+
def (self: Int) bar: Int = self
4+
1.foo(2).bar
5+
}

0 commit comments

Comments
 (0)