[Nice-devel] [ nice-Bugs-969777 ] Creating a closure in a custom constructor
Brought to you by:
bonniot
From: SourceForge.net <no...@so...> - 2004-06-10 14:04:50
|
Bugs item #969777, was opened at 2004-06-09 19:22 Message generated for change (Comment added) made by bonniot You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112788&aid=969777&group_id=12788 Category: None Group: None Status: Open >Resolution: Accepted Priority: 5 Submitted By: Bryn Keller (xoltar) >Assigned to: Daniel Bonniot (bonniot) >Summary: Creating a closure in a custom constructor Initial Comment: C:\src\nice>nicec --version Nice compiler version 0.9.8 prerelease (build 2004.05.28, 18:05:16 UTC) Compiled using JDK 1.4.2 Copyright (C) 2003 Daniel Bonniot Visit the Nice homepage: http://nice.sourceforge.net import java.awt.*; class Square extends Polygon { int x() = this.getBounds().x; int y() = this.getBounds().y; } <T,U> T fst((T,U) tup) { (T t,U u) = tup; return t; } <T,U> U snd((T,U) tup) { (T t, U u) = tup; return u; } new Square(int x, int y, int width) { let points = [(0,0), (0,1), (1,1), (1,0)]; this(points.map(fst), points.map(snd), points.length); } void main(String[] args) { } Compiles, but fails at runtime: C:\src\nice>java -jar test.jar Exception in thread "main" java.lang.VerifyError: (class: test/fun, method: x signature: (Ltest/Square;)I) Incompatible object argument for function call at test.dispatch.main(dispatch.nice) ---------------------------------------------------------------------- >Comment By: Daniel Bonniot (bonniot) Date: 2004-06-10 16:04 Message: Logged In: YES user_id=88952 This error arises when creating a closure inside a custom constructor (or an instance initializer). I'll fix it. If you need a workaround in the mean time, call a regular method from the custom constructor to do the job. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112788&aid=969777&group_id=12788 |