Community
Participate
Working Groups
With the following Xtend2 snippet: <T> test() { [T t|switch t { case t:test }] } I get a StackOverflowError from the builder (or the reconciler): java.lang.StackOverflowError at org.eclipse.xtext.common.types.impl.JvmParameterizedTypeReferenceImpl.getArguments(JvmParameterizedTypeReferenceImpl.java:92) at org.eclipse.xtext.common.types.impl.JvmParameterizedTypeReferenceImpl.eGet(JvmParameterizedTypeReferenceImpl.java:170) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1013) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1005) at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:409) at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:222) at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:188) at org.eclipse.emf.ecore.impl.MinimalEObjectImpl$1.didAdd(MinimalEObjectImpl.java:488) at org.eclipse.emf.ecore.impl.MinimalEObjectImpl$1.didAdd(MinimalEObjectImpl.java:1) at org.eclipse.emf.common.util.ArrayDelegatingEList.addUnique(ArrayDelegatingEList.java:395) at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307) at org.eclipse.emf.ecore.util.EContentAdapter.addAdapter(EContentAdapter.java:352) at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:225) at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:188) at org.eclipse.emf.ecore.impl.MinimalEObjectImpl$1.didAdd(MinimalEObjectImpl.java:488) at org.eclipse.emf.ecore.impl.MinimalEObjectImpl$1.didAdd(MinimalEObjectImpl.java:1) at org.eclipse.emf.common.util.ArrayDelegatingEList.addUnique(ArrayDelegatingEList.java:395) at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307) at org.eclipse.emf.ecore.util.EContentAdapter.addAdapter(EContentAdapter.java:352) at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:225) at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:188) at org.eclipse.emf.ecore.impl.MinimalEObjectImpl$1.didAdd(MinimalEObjectImpl.java:488) at org.eclipse.emf.ecore.impl.MinimalEObjectImpl$1.didAdd(MinimalEObjectImpl.java:1) at org.eclipse.emf.common.util.ArrayDelegatingEList.addUnique(ArrayDelegatingEList.java:395) at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307) at org.eclipse.emf.ecore.util.EContentAdapter.addAdapter(EContentAdapter.java:352) at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:225) By adding another case to the switch the error goes away: <T> test() { [T a|switch a { case null:null case a:test }] }
This one is tricky. The return type of test is effectivly Function1<T, [return type of test]>. It seems hard to track the origin of a type argument / type reference to detect this kind of recursion but it should be possible to use EAdapters that point to the origin of a type reference. This data could be used to identify that we run into an recursively nested structure. Maybe somebody has another idea?
It should be simpler to avoid copying proxies during the return type inference. Since we would run into recursive proxy resolution if the proxy is resolved prior to setting the value in its container, we could use the recursion detection from Xtend2Resource#getEObject
Preliminary scheduled for 2.0RC1
postponed to SR1
Just tried this example again and it can lead to all kinds of weird problems. Unfortunately the builder also doesn't get past a file with this content and of course also locks the file. So the user must in the end kill Eclipse and then on startup be fast and disable autobuild. Could this be the first Xtend virus? :-)
The StackOverflowError does no longer happen though you still get some strange error marker about dangling references but I bet this is better than a StackOverflow. Closed as fixed since the dangling references for erroneous are another topic.
Excellent!
Closing all bugs that were set to RESOLVED before Neon.0