-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix/overloaded access #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6eba6c9
f041ae0
00c3cb7
f37550d
cd60a3d
4acf8ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,6 @@ class Typer extends Namer with Applications with Implicits { | |
if (reallyExists(mbr)) site.select(name, mbr) | ||
else { | ||
if (!site.isErroneous) { | ||
typr.println(s"site = $site, baseClasses = ${site.baseClasses}") | ||
ctx.error( | ||
if (name == nme.CONSTRUCTOR) i"$site does not have a constructor" | ||
else i"$name is not a member of $site", pos) | ||
|
@@ -139,8 +138,7 @@ class Typer extends Namer with Applications with Implicits { | |
} | ||
val where = if (ctx.owner.exists) s" from ${ctx.owner.enclosingClass}" else "" | ||
val whyNot = new StringBuffer | ||
val addendum = | ||
alts foreach (_.isAccessibleFrom(pre, superAccess, whyNot)) | ||
alts foreach (_.isAccessibleFrom(pre, superAccess, whyNot)) | ||
if (!tpe.isError) | ||
ctx.error(i"$what cannot be accessed as a member of $pre$where.$whyNot", pos) | ||
ErrorType | ||
|
@@ -245,7 +243,7 @@ class Typer extends Namer with Applications with Implicits { | |
* does properly shadow the new one from an outer context. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have trouble understanding how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. found is new one. |
||
def checkNewOrShadowed(found: Type, newPrec: Int): Type = | ||
if (!previous.exists || (previous =:= found)) found | ||
if (!previous.exists || ctx.typeComparer.isSameRef(previous, found)) found | ||
else if ((prevCtx.scope eq ctx.scope) && | ||
(newPrec == definition || | ||
newPrec == namedImport && prevPrec == wildImport)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
object overloadedAccess { | ||
|
||
trait ST { | ||
def f(x: Object): Int = 1 | ||
def f(x: Int): Unit = () | ||
} | ||
|
||
object O extends ST { | ||
def f(x: String): Unit = () | ||
} | ||
|
||
class C extends ST { | ||
import O._ // needs to pick inherited member because they are made visible in same scope. | ||
val x = f("abc") | ||
val y: Int = x | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is executed just for side-effects?