[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-scm
Subject:    [groovy-scm]  [18175] trunk/groovy/groovy-core/src/test/groovy/bugs: GROOVY-3645
From:       roshandawrani () codehaus ! org
Date:       2009-10-31 18:39:49
Message-ID: 20091031183950.6B2EC15F01B3 () codehaus01 ! managed ! contegix ! com
[Download RAW message or body]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><style type="text/css"><!--
#msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : \
#fff; } #msg DT { float : left; width : 6em; font-weight : bold; }
#msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; \
font-size : 10pt;  } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; \
font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; \
background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, \
.diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; \
font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin \
: 0; } #patch .propset h4, #patch .binary h4 {margin: 0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {background:#eeeeee;padding: 0 0 10px 0;}
#patch .propset .diff, #patch .binary .diff  {padding: 10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add \
{background:#ddffdd;} #patch .rem {background:#ffdddd;}
#patch .lines, .info {color:#888888;background:#ffffff;}
.diff { width : 100%; }
#msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : \
#fff; } #msg DT { float : left; width : 6em; font-weight : bold; }
#msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; \
font-size : 10pt;  } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; \
font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; \
background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, \
.diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; \
font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin \
: 0; } #patch .propset h4, #patch .binary h4 {margin: 0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {background:#eeeeee;padding: 0 0 10px 0;}
#patch .propset .diff, #patch .binary .diff  {padding: 10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add \
{background:#ddffdd;} #patch .rem {background:#ffdddd;}
#patch .lines, .info {color:#888888;background:#ffffff;}
.diff { width : 100%; }
--></style>
<title> [18175] trunk/groovy/groovy-core/src/test/groovy/bugs: GROOVY-3645</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a \
href="http://fisheye.codehaus.org/changelog/groovy/?cs=18175">18175</a></dd> \
<dt>Author</dt> <dd>roshandawrani</dd> <dt>Date</dt> <dd>2009-10-31 13:39:48 -0500 \
(Sat, 31 Oct 2009)</dd> </dl>

<h3>Log Message</h3>
<pre><a href="http://jira.codehaus.org/secure/ViewIssue.jspa?key=GROOVY-3645">GROOVY-3645</a>
 Calling a method on &#39;super&#39; in a static method resulted in \
IncompatibleClassChangeError. Fixed it.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkgroovygroovycoresrcmainorgcodehausgroovycontrolStaticImportVisitorj \
ava">trunk/groovy/groovy-core/src/main/org/codehaus/groovy/control/StaticImportVisitor.java</a></li>
 </ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkgroovygroovycoresrctestgroovybugsGroovy3645Buggroovy">trunk/groovy/groovy-core/src/test/groovy/bugs/Groovy3645Bug.groovy</a></li>
 </ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkgroovygroovycoresrcmainorgcodehausgroovycontrolStaticImportVisitorjava"></a>
 <div class="modfile"><h4>Modified: \
trunk/groovy/groovy-core/src/main/org/codehaus/groovy/control/StaticImportVisitor.java \
(18174 => 18175)</h4> <pre class="diff">
<span class="info">--- \
trunk/groovy/groovy-core/src/main/org/codehaus/groovy/control/StaticImportVisitor.java	2009-10-31 \
                18:20:00 UTC (rev 18174)
+++ trunk/groovy/groovy-core/src/main/org/codehaus/groovy/control/StaticImportVisitor.java	2009-10-31 \
18:39:48 UTC (rev 18175) </span><span class="lines">@@ -161,9 +161,15 @@
</span><span class="cx">         Expression method = transform(mce.getMethod());
         Expression object = transform(mce.getObjectExpression());
         boolean isExplicitThisOrSuper = false;
</span><span class="add">+        boolean isExplicitSuper = false;
</span><span class="cx">         if (object instanceof VariableExpression) {
             VariableExpression ve = (VariableExpression) object;
             isExplicitThisOrSuper = !mce.isImplicitThis() &amp;&amp; \
(ve.getName().equals(&quot;this&quot;) || ve.getName().equals(&quot;super&quot;)); \
</span><span class="add">+            isExplicitSuper = \
ve.getName().equals(&quot;super&quot;); +            if (isExplicitSuper &amp;&amp; \
currentMethod != null &amp;&amp; currentMethod.isStatic()) { +                \
addError(&quot;&#39;super&#39; cannot be used in a static context, use the explicit \
class instead.&quot;, mce); +                return mce;
+            }
</span><span class="cx">         }
 
         if (mce.isImplicitThis() || isExplicitThisOrSuper) {
</span><span class="lines">@@ -247,7 +253,7 @@
</span><span class="cx">             VariableExpression ve = (VariableExpression) \
                objectExpression;
             boolean isExplicitSuper = ve.getName().equals(&quot;super&quot;);
             if (isExplicitSuper &amp;&amp; currentMethod != null &amp;&amp; \
currentMethod.isStatic()) { </span><span class="rem">-                \
addError(&quot;&#39;super&#39; cannot be used in a static context, ex the exlicit \
class instead.&quot;, pe); </span><span class="add">+                \
addError(&quot;&#39;super&#39; cannot be used in a static context, use the explicit \
class instead.&quot;, pe); </span><span class="cx">                 return null;
             }
         }
</span></pre></div>
<a id="trunkgroovygroovycoresrctestgroovybugsGroovy3645Buggroovy"></a>
<div class="addfile"><h4>Added: \
trunk/groovy/groovy-core/src/test/groovy/bugs/Groovy3645Bug.groovy (0 => 18175)</h4> \
<pre class="diff"> <span class="info">--- \
trunk/groovy/groovy-core/src/test/groovy/bugs/Groovy3645Bug.groovy	                   \
                (rev 0)
+++ trunk/groovy/groovy-core/src/test/groovy/bugs/Groovy3645Bug.groovy	2009-10-31 \
18:39:48 UTC (rev 18175) </span><span class="lines">@@ -0,0 +1,20 @@
</span><span class="add">+package groovy.bugs
+
+import org.codehaus.groovy.control.MultipleCompilationErrorsException
+
+class Groovy3645Bug extends GroovyTestCase {
+    void testMethodCallOnSuperInAStaticMethod() {
+        try{
+            assertScript &quot;&quot;&quot;
+                class Foo3645 {
+                    static main(args) {
+                        super.bar()
+                    }
+                }
+            &quot;&quot;&quot;
+            fail(&quot;Script compilation should have failed saying that \
&#39;super&#39; cannot be used in a static context.&quot;) +        } \
catch(MultipleCompilationErrorsException ex) { +            assertTrue \
ex.message.contains(&quot;&#39;super&#39; cannot be used in a static context&quot;) + \
} +    }
+}
</span><span class="cx">\ No newline at end of file
</span>
</pre>
</div>
</div>

</body>
</html>

<hr/>
<p>
To unsubscribe from this list please visit:
</p>
<p>
    <a href="http://xircles.codehaus.org/manage_email">http://xircles.codehaus.org/manage_email</a>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic