Skip to content

Fixes for various txxxx tickets #86

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

Merged
merged 22 commits into from
Mar 24, 2014
Merged

Fixes for various txxxx tickets #86

merged 22 commits into from
Mar 24, 2014

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 20, 2014

No description provided.

@odersky
Copy link
Contributor Author

odersky commented Mar 20, 2014

This is a long list of fixes to make existing Scala test cases pass, or to invalidate the test cases. Review by @gzm0 and @sjrd, sheparding by @gzm0 please.

@DarkDimius
Copy link
Contributor

Please not that first two commits are already effectively merged into master, but with different sha1(changed during rebase)

@odersky
Copy link
Contributor Author

odersky commented Mar 20, 2014

Yes, I had lots of merge conflicts when I pulled from master. Maybe that's because of this.

@gzm0
Copy link
Contributor

gzm0 commented Mar 20, 2014

I will remove these two commits (they undo each other)

@sjrd
Copy link
Member

sjrd commented Mar 20, 2014

That's all for me.

@gzm0
Copy link
Contributor

gzm0 commented Mar 20, 2014

Otherwise LGTM for me. I will update the commits.

@gzm0
Copy link
Contributor

gzm0 commented Mar 21, 2014

Updated commits according to comments. IMHO we can merge this as soon as CI passes.

@sjrd
Copy link
Member

sjrd commented Mar 21, 2014

Yep, except that apparently GitHub can't merge it automatically ... Rebase on top of master?

@gzm0
Copy link
Contributor

gzm0 commented Mar 21, 2014

Aarrrgh... Is there I way I can see that? Will rebase

odersky added 21 commits March 21, 2014 11:24
Test t0288 moved to disabled due to lack of Java interop.
Test t0273 fixed by relaxing double def condition: We only regard two
definitions that define the same name and have exactly the same signature
as double definitions. Previously, signatures that defined the same parameters
were also excluded.
Two fixes were needed

1) When typing a function value (x1: T1, ..., xN: Tn) => e, don't unconditionally issue an error
   if the expected function type arity is different from N. Instead, issue an error only
   if one of the types T1, ..., Tn is absent. The idea is that only then we need to
   consult the expected type for the parameter type. This allows to fix the problem later
   by an implicit conversion applied to the function value.

2) When eta-expanding, do not automtically take the arity of the expected function value as the
   arity of the generated lambda. Instead, take the method's arity, and copy method parameters
   into the lambda in case the arities are different.
_root_ is now entered into an enclosing context.
A debug assertion in implicitSearch gave a false alarm and was removed.
Added more tests which all pass, except for tests in disabled and pending.

t0694 went from pos to neg, because the kind of alias type used in t0695 is no longer supported.
Previously, only implicit method types were eligible as views. This is too strict,
as it rules out view bounds. We now also consider types that derive from Function1.
The reason for not allowing any type is that this would cause us to check many more
types for applicability when an implicit view is searched.
Was previously wrapped in a

    package <empty>

but the resulting tree had no position, which caused a Typer assertion. If now
represented as EmptyTree.
which all pass.
Method type comparison via <:< yielded false if the signatures of the two method types differed.
This is too strict, because methods can have the same parametyers but different result types and still
be in a subtype relationship. We now onyl demand that the sighatures have the same parameters.
type T was not recorgnized as a SAM type because a case was missing in zeroParamClass.
Needed an extra case in isSubType.
Need to do unit discarding also in selection prototypes.
The original test is now in error because the type Meta in the prefix Meta#Event
is not stable and contains an abstract member Slog.

Even after removing Slog, the test in pos was still in error because the bound type parameters
were incorrectly recognized as abstract members. This has been fixed by the changes to Types.
The type of self name "x" was taken to be the thisType of the current owner.
But the current owner was a local dummy of the class in question, so the ThisType
was NoPrefix. Inserting an enclosingClass fixes the problem.
(and also of t0625, which reappeared).

Several fixes were made. In summary:

1. Naming and representation of KigherKinded traits changed. It's now $HigherKinded$NIP where
the letters after the second $ indicate variance (N)egative, (I)nvariant, (P)ositive. The HKtraits
themselves are always non-variant in their parameters.

2. When deriving refined types over higher-kinded types, the variance of a type alias
is the variance of the new type constructor.

3. isSubTypeHK was changed, as was the position from where it is called.

4. appliedTo also works for PolyTypes.
Mostly Java interop tests which are not yet supported. The test infrastructure for Java ocmpilation and the java parser from Scala are still missing.
Turned parameter into receiver (reciever was not used before at all).
baseTypeWithArgs now also keeps track of refinements in the subtypes. Without
that, the approximated lub in t1279a is too coarse and the program fails to typecheck.
test case t0273. Was positive in Scala 2, is now deemed to be negative.
Two two definitions

    def a = () => ()
    def a[T] = (p:A) => ()

do have matching signatures, so should constitute a double definition.
I previously thought that we can get away if the two definitions have
different result types, but then you immediately have a problem because
the denotations have matching signatures for the pruposes of "&" yet
cannot be merged. Which of the two definitions would override
a definition in a base class is then an arbitrary decision.
stripImplicits needs to take polytypes into account.
@gzm0
Copy link
Contributor

gzm0 commented Mar 21, 2014

Rebased.

@sjrd
Copy link
Member

sjrd commented Mar 21, 2014

And now travis failed ...

@gzm0
Copy link
Contributor

gzm0 commented Mar 21, 2014

@odersky this is caused by the rebase itself and is an incompatibility between the changes with #88.

The tips before my rebases are as follows:

The diff between the tips before the rebase on master is trivial (gzm0/dotty@4d7ee1d ... gzm0/dotty@0e6a79e)

diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index ba411d4..d66d406 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -921,10 +921,10 @@ class TypeComparer(initctx: Context) extends DotClass {

   /** Try to distribute `&` inside type, detect and handle conflicts */
   private def distributeAnd(tp1: Type, tp2: Type): Type = tp1 match {
+    // opportunistically merge same-named refinements
+    // this does not change anything semantically (i.e. merging or not merging
+    // gives =:= types), but it keeps the type smaller.
     case tp1: RefinedType =>
-      // opportunistically merge same-named refinements
-      // this does not change anything semantically (i.e. merging or not merging
-      // gives =:= types), but it keeps the type smaller.
       tp2 match {
         case tp2: RefinedType if tp1.refinedName == tp2.refinedName =>
           tp1.derivedRefinedType(
diff --git a/tests/neg/t0654.scala b/tests/neg/t0654.scala
index b4a3f68..52dbbb0 100644
--- a/tests/neg/t0654.scala
+++ b/tests/neg/t0654.scala
@@ -2,5 +2,4 @@ object Test {
   class Foo[T]
   type C[T] = Foo[_ <: T]   // error: parameter type T of type alias does not appear as type argument of the aliased class Foo
   val a: C[AnyRef] = new Foo[AnyRef] // follow-on error: wrong number of type arguments for Test.C, should be 0
-
 }
diff --git a/tests/pos/t1292.scala b/tests/pos/t1292.scala
index 2baa9d8..8e69734 100644
--- a/tests/pos/t1292.scala
+++ b/tests/pos/t1292.scala
@@ -9,8 +9,7 @@ trait Foo[T <: Foo[T, Enum], Enum <: Enumeration] {

 trait MegaFoo[T <: Foo[T, Enum], Enum <: Enumeration] extends Foo[T, Enum] {
   def doSomething(what: T, misc: StV, dog: Meta#Event) = None
-    // error: Meta is not a valid prefix for '#'.
-    // The error is correct. Meta is not stable, and it has an abstract type member Slog
+
   abstract class Event
   object Event

Fix of d6df293. It turned out the original commit
was faulty in that iterator.flatten did not typecheck. The problem is fixed in this
commit and flatten is added to the collections test.
@odersky
Copy link
Contributor Author

odersky commented Mar 21, 2014

Should be OK now. Over to @gzm0

@gzm0
Copy link
Contributor

gzm0 commented Mar 24, 2014

LGTM @sjrd?

@sjrd
Copy link
Member

sjrd commented Mar 24, 2014

LGTM

sjrd added a commit that referenced this pull request Mar 24, 2014
Fixes for various txxxx tickets
@sjrd sjrd merged commit 83449e1 into scala:master Mar 24, 2014
WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this pull request Mar 19, 2025
Backport "fix: don't consider `into` as a soft-modifier" to 3.3 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants