D6272: Declare variables in parameters of function literals

Mikhail Ivchenko noreply at phabricator.kde.org
Mon Jun 19 12:42:11 UTC 2017


ematirov created this revision.
ematirov added a project: KDevelop.
Restricted Application added a subscriber: kdevelop-devel.

REVISION SUMMARY
  Consider a following code:
  
    package main
    
    import "fmt"
    
    func passFuncAsArgument(a interface{}) interface{} { return a }
    
    func main() {
        a := func(test int) (int) { return test } // Declaring a local function literal  (1)
        func(test int) (int)  { return test } (5) // Calling a anonymous function  (2)
        passFuncAsArgument(func(test int) (int) {return test }) // Passing anonymous function as argument  (3)
        fmt.Println(a(5))
    }
  
  Before this patch only in (1) case a function argument will be added as declaration.
  This patch extends that to (2) and (3) cases.
  
  This has impact on semantic highlighting for example:
  Before
  F3787414: function_arguments_before.png <https://phabricator.kde.org/F3787414>
  After
  F3787421: function_arguments_after.png <https://phabricator.kde.org/F3787421>

TEST PLAN
  Tests were added and are passing fine.

REPOSITORY
  R59 KDevelop Go

BRANCH
  master

REVISION DETAIL
  https://phabricator.kde.org/D6272

AFFECTED FILES
  duchain/builders/declarationbuilder.cpp
  duchain/builders/declarationbuilder.h
  duchain/tests/testduchain.cpp
  duchain/tests/testduchain.h

To: ematirov, brauch, apol
Cc: kdevelop-devel, geetamc, Pilzschaf, akshaydeo, surgenight, arrowdodger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170619/7c2a9f7f/attachment.html>


More information about the KDevelop-devel mailing list